package com.uhylab.uhuvinetest.adapter;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.uhylab.uhuvinetest.R;

/**
 * Created by xyb on 15/12/8 at UHylab
 *
 * @version 1.0
 */
public class UHGuideVP_Adapter extends PagerAdapter {
    private Context context;
    private int imgs[] = {
            R.mipmap.guide_one, R.mipmap.guide_two, R.mipmap.guide_three
    };
    private ImageView guide_img;

    public UHGuideVP_Adapter(Context context) {
        this.context = context;
    }

    @Override
    public int getCount() {
        return imgs.length;
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        View view = LayoutInflater.from(context).inflate(R.layout.guidevp_item, null);
        guide_img = (ImageView) view.findViewById(R.id.guide_img);
        guide_img.setImageResource(imgs[position]);
        container.addView(view);
        return view;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
    }
}
